home *** CD-ROM | disk | FTP | other *** search
- /*
- * Implement the "suggestion" box, to catch user's comments,
- * and also a simple tracking mechanism, to send a blip of
- * mail from the first-time user. This is akin to releasing
- * helium balloons with postcards that say "If you find me,
- * send this card back to . . ." -- it should be interesting
- * to the community to track the free flow of software on
- * the ethernet.
- *
- * If you have any concerns about this, please check with me.
- *
- * Michael Hawley
- * mike@media-lab.mit.edu
- */
-
- #define _NAME "StereoScope"
-
- static char *stripnl(char *s){
- char *p;
- for (p=s;*p;p++) if (*p == '\n' || *p == '\r') *p = '\0';
- return s;
- }
-
- char *
- execstr(s) char *s; {
- FILE *f = popen(s,"r");
- char *p = s;
- *s = '\0';
- if (f){
- while (fgets(p,256,f))
- stripnl(p), p += strlen(p);
- pclose(f);
- }
- return s;
- }
-
- static void
- monitorMail(subj,body,dest) char *subj, *body, *dest; {
- char s[1024], u[256]="whoami", m[256]="hostname", t[4096];
- FILE *f, *popen();
- if (!dest || !*dest) dest = "woo@ornl.gov";
- execstr(u); execstr(m);
- if (!body || !*body){
- body = t;
- sprintf(body, "%s@%s\nIf this mail bounces back to you,\n\
- could you please correct the destination path if possible,\n\
- and send it to woo@ornl.gov.\n\
- We are trying an experiment to track software.\n",u,m);
- }
- sprintf(s,"/usr/ucb/Mail -s \"%s %s@%s\" %s",
- subj && *subj? subj : [NXApp appName], u, m, dest);
- if (f = popen(s,"w"))
- fprintf(f,"%s",body), pclose(f);
- }
-
- static void
- monitor(subj) char *subj; { // send a note at first use. to track net.
- extern char FirstUsed[];
- if (!*FirstUsed){
- extern long time();
- extern char *ctime();
- long t = time(0);
- if (t < 793414430) // 1995
- monitorMail(subj,0,0);
- strcpy(FirstUsed,ctime(&t));
- stripnl(FirstUsed);
- [_defaults writeDefaults:_defaults];
- }
- }
-
- - suggestion:sender {
- char subj[256], w[256] = "whoami";
- char body[4096]="\
- John:\n\n\
- A handy bit of software! I use it ALL the time.\n\
- Now, I know I should be sending you a T shirt, a card, \n\
- maybe a tax deductible surprise to assist in feeding your\n\
- hungry family, but all I have are these scrimpy electronic\n\
- comments:\n\n\
- <insert accolades & suggestions here>\n\n\
- parsimoniously,\n\
- ";
- #define fcall(a) [s performRemoteMethod:a]
- #define call(a,b) [s performRemoteMethod:a with:b length:strlen(b)+1]
- id s = [NXApp appSpeaker];
- NXPortFromName("Mail", NULL); // make sure app is launched
- [s setSendPort:NXPortFromName("MailSendDemo", NULL)];
-
- sprintf(subj,"Comments and suggestions for ``%s'' ",_NAME);
- strcat(subj,[version stringValue]);
- strcat(body,execstr(w)); strcat(body,"\n");
- call("setTo:","woo@ornl.gov");
- call("setSubject:",subj);
- call("setBody:",body);
-
- return self;
- }
-
- /*
- monitor("StereoScope-1.0-newuser");
- */
-